"""

"""
from selenium.webdriver.common.by import By
from basic.s15_dcd_page_base import BasePage


class LoginPage(BasePage):
    _url = 'https://www.dongchedi.com/'
    _login_button = (By.CSS_SELECTOR, '.new-user_login-btn__UneJM')
    _login_password = (By.CSS_SELECTOR, '.login-switch-button')
    _account = (By.CSS_SELECTOR, '[name="account"]')
    _password = (By.CSS_SELECTOR, '[name="password"]')
    _login = (By.CSS_SELECTOR, '.login-confirm-button')
    _user_img = (By.CSS_SELECTOR, '[alt^="用户"]')

    def get(self):
        self.driver.get(self._url)

    def login(self, username, password):
        self.click_visibility_by_locator(self._login_button)
        self.click_visibility_by_locator(self._login_password)
        self.find_ele_visibility(self._account).send_keys(username)
        self.find_ele_visibility(self._password).send_keys(password)
        self.click_visibility_by_locator(self._login)

    def user_img_alt(self):
        ele_user_img = self.find_ele_visibility(self._user_img)
        return ele_user_img.get_attribute('alt')
